package com.shishuo.base;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

public abstract class BaseController<T extends BaseEntity> {
	
	protected final Logger logger = Logger.getLogger(this.getClass());
	
	/**
	 * <p>
	 * Description: 通用页面跳转
	 * </p>
	 * @author XQF SUI
	 * @created 2016年5月24日 下午4:39:55
	 * @param request
	 * @param path 需要跳转的页面名称(不包含后缀)
	 * @return
	 */
	@RequestMapping(value = "jump/{path}", method = RequestMethod.GET)
	public String jump(HttpServletRequest request, @PathVariable(value = "path") String path) {
		String requestUrl = request.getRequestURI();
		
		if (StringUtils.isNotBlank(requestUrl)) {
			requestUrl = requestUrl.substring(1);
			requestUrl = requestUrl.substring(0, requestUrl.indexOf("/"));
		}
		
		return requestUrl + "/" + path;
	}
}
